home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / minix / includ~1.z / includ~1 / fcntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-05  |  3.1 KB  |  81 lines

  1. /* The <fcntl.h> header is needed by the open() and fcntl() system calls,
  2.  * which  have a variety of parameters and flags.  They are described here.  
  3.  * The formats of the calls to each of these are:
  4.  *
  5.  *    open(path, oflag [mode])    open a file
  6.  *    fcntl(fd, cmd,[ arg])        get or set file attributes
  7.  * 
  8.  */
  9.  
  10. #ifndef _FCNTL_H
  11. #define _FCNTL_H
  12.  
  13. /* These values are used for cmd in fcntl().  POSIX Table 6-1.  */
  14. #define F_DUPFD            0    /* duplicate file descriptor */
  15. #define F_GETFD               1    /* get file descriptor flags */
  16. #define F_SETFD            2    /* set file descriptor flags */
  17. #define F_GETFL            3    /* get file status flags */
  18. #define F_SETFL            4    /* set file status flags */
  19. #define F_GETLK            5    /* get record locking information */
  20. #define F_SETLK            6    /* set record locking information */
  21. #define F_SETLKW           7    /* set record locking info; wait if blocked */
  22.  
  23. /* File descriptor flags used for fcntl().  POSIX Table 6-2. */
  24. #define FD_CLOEXEC         1    /* close on exec flag for third arg of fcntl */
  25.  
  26. /* L_type values for record locking with fcntl().  POSIX Table 6-3. */
  27. #define F_RDLCK            0    /* shared or read lock */
  28. #define F_WRLCK            1    /* exclusive or write lock */
  29. #define F_UNLCK            2    /* unlock */
  30.  
  31. /* Oflag values for open().  POSIX Table 6-4. */
  32. #define O_CREAT        001000    /* creat file if it doesn't exist */
  33. #define O_EXCL         004000    /* exclusive use flag */
  34. #define O_NOCTTY       040000    /* do not assign a controlling terminal */
  35. #define O_TRUNC        002000    /* truncate flag */
  36. #ifdef KERNEL
  37. #define        O_FIRSTOPEN 010000
  38. #define        O_LASTCLOSE 020000
  39. /* used in fs */
  40. #define     O_LEGAL (O_WRONLY|O_RDWR|O_NONBLOCK|O_APPEND|O_CREAT|O_TRUNC|O_EXCL)
  41. #define     F_FL_LEGAL    (O_NONBLOCK|O_APPEND)
  42. #endif
  43.  
  44. /* File status flags for open() and fcntl().  POSIX Table 6-5. */
  45. #define O_APPEND       00010    /* set append mode */
  46. #define O_NONBLOCK     00004    /* no delay */
  47.  
  48. /* File access modes for open() and fcntl().  POSIX Table 6-6. */
  49. #define O_RDONLY           0    /* open(name, O_RDONLY) opens read only */
  50. #define O_WRONLY           1    /* open(name, O_WRONLY) opens write only */
  51. #define O_RDWR             2    /* open(name, O_RDWR) opens read/write */
  52.  
  53. /* Mask for use with file access modes.  POSIX Table 6-7. */
  54. #define O_ACCMODE         03    /* mask for file access modes */
  55.  
  56. /* Struct used for locking.  POSIX Table 6-8. */
  57. struct flock {
  58.   short l_type;            /* type: F_RDLCK, F_WRLCK, or F_UNLCK */
  59.   short l_whence;        /* flag for starting offset */
  60.   off_t l_start;        /* relative offset in bytes */
  61.   off_t l_len;            /* size; if 0, then until EOF */
  62.   pid_t l_pid;            /* process id of the locks' owner */
  63. };
  64.  
  65.  
  66. /* Function Prototypes. */
  67. #ifndef _ANSI_H
  68. #include <ansi.h>
  69. #endif
  70.  
  71. _PROTOTYPE( int creat, (const char *__path, int __mode)               );
  72. #ifdef __SRC__
  73. _PROTOTYPE( int fcntl, (int __filedes, int __cmd, int arg)          );
  74. _PROTOTYPE( int open,  (const char *__path, int __oflag, int __mode)    );
  75. #else
  76. _PROTOTYPE( int fcntl, (int __filedes, int __cmd, ...)          );
  77. _PROTOTYPE( int open,  (const char *__path, int __oflag, ...)         );
  78. #endif
  79.  
  80. #endif /* _FCNTL_H */
  81.